﻿// DigitalDesign
// Project: InformationBoard
// Developer: Montak Oleg
// Created: 15.11.2011
// Last change: 16.11.2011
// Description: extension methods for EF-entities

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Server
{
    public partial class Schedule
    {
        public void Update(wScheduleNode wSchedule)
        {
            NumberOfTransport = wSchedule.NumberOfTransport;
            StationOfDestination = wSchedule.StationOfDestination;
            TimeOfDeparture = wSchedule.TimeOfDeparture;
            TimeOfLanding = wSchedule.TimeOfLanding;
            LocationId = wSchedule.LocationId;

            DaysOfWeek.Clear();
            foreach (var wDay in wSchedule.DaysOfWeek)
            {
                var newDay = Context.Instance.DaysOfWeeks.SingleOrDefault(d => d.Id == wDay.Id);

                if (newDay != null)
                    DaysOfWeek.Add(newDay);
            }
        }
    }
}
